package com.tiku.controller;

import com.tiku.common.ResultJson;
import com.tiku.controller.TO.UserParamTO;
import com.tiku.controller.TO.UserRegisterTo;
import com.tiku.service.UserInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@RestController
@RequestMapping("/users")
@CrossOrigin("*")
@Api("用户接口")
public class UserController {

    @Autowired
    private UserInfoService userInfoService;


    @PostMapping("/login")
    @ApiOperation("用户登录")
    public ResultJson login(@RequestBody UserParamTO userParamTO){
        return userInfoService.login(userParamTO);
    }

    @PostMapping("/register")
    @ApiOperation("用户注册")
    public ResultJson register(@RequestBody UserRegisterTo userRegisterTo){
        return userInfoService.register(userRegisterTo);
    }

    @PostMapping("/send")
    @ApiOperation("发送验证码")
    public ResultJson send(@RequestBody UserRegisterTo userRegisterTo){
        return userInfoService.send(userRegisterTo.getPhone().trim(),userRegisterTo.getType());
    }
    @PostMapping("/updatePwd")
    @ApiOperation("更改密码")
    public ResultJson updatePwd(@RequestBody UserRegisterTo userRegisterTo){
        return userInfoService.updatePwd(userRegisterTo);
    }

}
